/****************************************/
/*				PRELOAD IMGs			*/
/****************************************/

(function($) {
  var cache = [];
  // Arguments are image paths relative to the current page.
  $.preLoadImages = function() {
    var args_len = arguments.length;
    for (var i = args_len; i--;) {
      var cacheImage = document.createElement('img');
      cacheImage.src = arguments[i];
      cache.push(cacheImage);
    }
  }
})(jQuery)


/****************************************/
/*				  UNIQUE ID				*/
/****************************************/

function blg_uniqid_generator() {
    var S4 = function() {
       return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
    };
    return (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4());
}

/****************************************/
/*				  STRINGS 				*/
/****************************************/

function blg_file_get_extension(file){
	var extension = file.substr((file.lastIndexOf('.') +1)).toLowerCase();
	return extension;
}

/****************************************/
/*				  VALIDATE 				*/
/****************************************/

function v_is_email(address){
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	if(reg.test(address) == false) {
		return false;
	}
	
	return true;
}

function v_is_alphanumeric(str){
	var alphaExp = /^[0-9a-zA-Z]+$/;
	if(str.match(alphaExp)){
		return true;
	}else{
		return false;
	}
}

function v_is_valid_extension(filename, valid_extensions){
	var ext = blg_file_get_extension(filename);
	
	if($.inArray(ext, valid_extensions) == -1){
    	return false;
	}
	
	return true;


}


